// Mixins
@mixin button-color($type, $color) {
	&.cl-button--#{$type} {
		background-color: $color;
		border-color: $color;
		.cl-button__text {
			color: #fff;
		}
		&.is-plain {
			background-color: #fff;
			.cl-button__text {
				color: rgba($color, 0.8);
			}
			&.is-border {
				border-color: rgba($color, 0.8);
			}
		}
		&.is-disabled {
			background-color: $color;
		}
		&.button-hover {
			&:not(.is-loading) {
				background-color: rgba($color, 0.8);
				&.is-plain {
					.cl-button__text {
						color: #fff;
					}
				}
			}
		}
	}
}

// Styles
.cl-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	white-space: nowrap;
	margin: 0;
	background-color: #fff;
	overflow: visible;
	vertical-align: middle;
	font-size: $cl-button-font-size;
	border-radius: $cl-button-border-radius;

	&__text {
		display: inline;
		color: #666;
	}

	&__icon {
		margin-right: 10rpx;

		image {
			height: 50rpx;
			width: 50rpx;
		}
	}

	&::after {
		display: none;
		border-width: 0;
	}

	&.button-hover {
		background-color: #f7f7f7;
	}

	&--large {
		height: 80rpx;
		padding: 0rpx 38rpx;
	}

	&--default {
		height: $cl-button-height;
		padding: $cl-button-padding;
	}

	&--small {
		font-size: 24rpx;
		height: 48rpx;
		padding: 0rpx 22rpx;
	}

	&.is-border {
		border: $cl-button-border-width solid $cl-button-border-color;
	}

	&.is-round {
		border-radius: $cl-button-round-border-radius !important;
	}

	&.is-loading {
		opacity: 0.7;
		.cl-button__loading {
			display: inline-flex;
			align-items: center;
		}
		.cl-button__text {
			margin-left: 15rpx;
		}
	}

	&.is-fill {
		width: 100%;
	}

	&.is-disabled {
		opacity: 0.5;
	}

	&.is-bold {
		font-weight: bold;
	}

	&.is-loading-mask {
		position: relative;
		&::after {
			content: "";
			background-color: rgba(0, 0, 0, 0.5);
			height: 100%;
			width: 100%;
			position: absolute;
			left: 0;
			top: 0;
		}
		.cl-button__loading {
			position: absolute;
			left: auto;
			top: auto;
			z-index: 9;
			display: inline-flex;
			align-items: center;
			&-text {
				margin-left: 10rpx;
			}
		}
	}

	// Colors
	@include button-color(primary, $cl-color-primary);
	@include button-color(success, $cl-color-success);
	@include button-color(error, $cl-color-error);
	@include button-color(warning, $cl-color-warning);
	@include button-color(info, $cl-color-info);
}

// Adjacent selectors
.cl-button + .cl-button,
cl-button + cl-button {
	margin-left: 20rpx;
}
